package cn.smile.controller.wechat;

import cn.smile.bean.dto.wechat.MediaUploadDTO;
import cn.smile.business.wechat.IWeChatApiService;
import cn.smile.commons.response.MyResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/weChatApi")
public class WeChatAccountController {
    @Resource
    private IWeChatApiService service;

    @GetMapping(value = "getAccessToken")
    public MyResult<String> getAccessToken(@RequestParam(value = "appId") String appId, @RequestParam(value = "appSecret") String appSecret, @RequestParam(value = "refresh") Boolean refresh) {
        return MyResult.OK(service.getAccessToken(appId, appSecret, refresh));
    }

    @PostMapping(value = "uploadMedia")
    public MyResult<MediaUploadDTO> uploadMedia(@RequestParam(value = "appId") String appId, @RequestParam(value = "fileUrl") String fileUrl) {
        return MyResult.OK(service.uploadMedia(fileUrl, appId));
    }
}
